//
//  TopApi.h
//  mcf
//
//  Created by yuike6 yuike6 on 12-1-7.
//  Copyright (c) 2012年 yuike. All rights reserved.
//



/*
 参数签名,分两种:
 1 未登录公式: md5(appSecret+api+v+imei+imsi+md5(d ata)+t)如果涉及到编码请使用gbk编码进行加 签
 2 已登录公式:
 md5 (ecode+appSecret+api+v+imei+imsi+m d5(data)+t) 其中的ecode是登录后登录接口 返回的 
 
 ------------------------------------------------------------------
 
 以 json 来 描 述 的 数 据 字 段 如 : {“a”:”av”,”b”:”bv”} 简单期间如果一个key 传入多值,采用逗号分割,如: {“as”:”a1,a2,a3”}
 
 ------------------------------------------------------------------
 
 TTID是一个字符串，基本的组成为“渠道代码_AppKey@应用名称_平台名称_版本号_特殊参数（可选）”。
 
 ------------------------------------------------------------------
 
 @"http://gw.api.taobao.com/router/rest?sign=6C9C7B4AED8DCA9A5ABC45C528A38E84&timestamp=2012-03-13+15%3A13%3A21&v=2.0&app_key=12129701&method=taobao.taobaoke.items.convert&partner_id=top-apitools&format=json&nick=gangwangchina&num_iids=13407428302&fields=click_url,num_iid,commission,commission_rate,commission_num,commission_volume"
 
 
 @"http://gw.api.taobao.com/router/rest?sign=_PARAM_TOP_SIGN_&timestamp=_PARAM_TOP_TIMESTAMP_v=2.0&app_key=_PARAM_TOP_APPKEY_&method=_PARAM_TOP_METHOD_&partner_id=top-apitools&format=json&nick=_PARAM_TOP_NICK_&is_mobile=true&num_iids=_PARAM_TOP_PRODUCTIDS_&fields=click_url,num_iid,commission,commission_rate,commission_num,commission_volume"
 
 ------------------------------------------------------------------
 */

#ifndef mcf_TopApi_h
#define mcf_TopApi_h

#define TOP_API_TEMPLATE_WIRELESS        @"http://api.m.taobao.com/rest/api2.do?api=%%api%%&v=%%v%%&imei=%%imei%%&imsi=%%imsi%%&appkey=%%appkey%%&data=%%data%%&sign=%%sign%%&t=%%t%%&ttid=%%ttid%%"

#define TOP_API_TEMPLATE       @"http://%%api%%"
#define _PARAM_TOP_API_                         @"%%api%%"
#define _PARAM_TOP_V_                           @"%%v%%"
#define _PARAM_TOP_IMEI_                        @"%%imei%%"
#define _PARAM_TOP_IMSI_                        @"%%imsi%%"
#define _PARAM_TOP_APPKEY_                      @"%%appkey%%"
#define _PARAM_TOP_DATA_                        @"%%data%%"
#define _PARAM_TOP_SIGN_                        @"%%sign%%"
#define _PARAM_TOP_T_                           @"%%t%%"
#define _PARAM_TOP_TTID_                        @"%%ttid%%"
#define _PARAM_TOP_TIMESTAMP_                   @"%%timestamp%%"
#define _PARAM_TOP_METHOD_                      @"%%method%%"
#define _PARAM_TOP_NICK_                        @"%%nick%%"
#define _PARAM_TOP_NICKS_                       @"%%nicks%%"
#define _PARAM_TOP_PRODUCTIDS_                  @"%%num_iids%%"
#define _PARAM_TOP_PRODUCTID_                   @"%%num_iid%%"
#define _PARAM_TOP_IS_MOBILE_                   @"%%is_mobile%%"
#define _PARAM_TOP_SELLER_NICK                  @"%%seller_nick%%"

#define _PARAM_TAOBAO_PRODUCTID_                @"%%productid%%"


#define _PARAM_TOP_DATA_APPKEY_                 @"appkey"
#define _PARAM_TOP_DATA_CALLBACK                @"callbackUrl"

#define _TOP_API_RECV_RET_                      @"ret"
#define _TOP_API_RECV_DATA_                     @"data"


#define TOP_API_ROOT                            @"http://api.m.taobao.com/rest/api2.do?"

#define TOP_API_USER_LOGOIN                             @"com.taobao.wireless.mtop.getLoginUrl"
#define TOP_API_USER_AUTO_LOGOIN                        @"com.taobao.client.sys.autologin"

#define TOP_API_GET_USER_SESSION_KEY                    @"com.taobao.client.mtop.getUserSessionKey"
#define TOP_API_AUTO_LOGOIN                             @"com.taobao.client.sys.Nautologin"

#define TOP_API_TAOKE_CONVERT                           @"taobao.taobaoke.items.convert"

#define TOP_API_ITEM_GET                                @"taobao.item.get"

#define TOP_API_USER_GET                                @"taobao.user.get"
#define TOP_API_USERS_GET                                @"taobao.users.get"

//获取商品评论Api http ://api.taobao.com/apidoc/api.htm?path=cid:6-apiId:10559
#define TOP_API_TRADERATES_SEARCH                       @"taobao.traderates.search"


//#define TOP_API_TAOKE_CONVERT_API_TEMPLATE              @"http ://gw.api.taobao.com/router/rest?sign=%%sign%%&timestamp=%%timestamp%%&v=2.0&app_key=%%appkey%%&method=%%method%%&partner_id=top-apitools&format=json&nick=%%nick%%&is_mobile=true&num_iids=%%num_iids%%&fields=click_url,num_iid,commission,commission_rate,commission_num,commission_volume"
#define TOP_API_TAOKE_CONVERT_API_TEMPLATE              @"http://gw.api.taobao.com/router/rest?sign=%%sign%%&ttid=%%ttid%%&imei=%%imei%%&imsi=%%imsi%%&timestamp=%%timestamp%%&v=2.0&app_key=%%appkey%%&method=%%method%%&format=xml&nick=%%nick%%&is_mobile=%%is_mobile%%&num_iids=%%num_iids%%&fields=click_url,num_iid,commission,commission_rate,commission_num,commission_volume&sign_method=md5"

#define TOP_API_ITEM_GET_API_TEMPLATE                   @"http://gw.api.taobao.com/router/rest?sign=%%sign%%&timestamp=%%timestamp%%&v=2.0&app_key=%%appkey%%&method=%%method%%&format=xml&num_iid=%%num_iid%%&fields=detail_url,num_iid,title,nick,type,cid,seller_cids,props,input_pids,input_str,desc,pic_url,num,valid_thru,list_time,delist_time,stuff_status,location,price,post_fee,express_fee,ems_fee,has_discount,freight_payer,has_invoice,has_warranty,has_showcase,modified,increment,approve_status,postage_id,product_id,auction_point,property_alias,item_img,prop_img,sku,video,outer_id,is_virtual&sign_method=md5"

#define TOP_API_TRADERATES_SEARCH_TEMPLATE                       @"http://gw.api.taobao.com/router/rest?sign=%%sign%%&timestamp=%%timestamp%%&v=2.0&app_key=%%appkey%%&method=%%method%%&format=xml&num_iid=%%num_iid%%&seller_nick=%%seller_nick%%&sign_method=md5"

/*
 需要放后在线参数中去
#define TOP_API_USER_GET_TEMPLATE                       @"http://gw.api.taobao.com/router/rest?sign=%%sign%%&timestamp=%%timestamp%%&v=2.0&app_key=%%appkey%%&method=%%method%%&format=xml&nick=%%nick%%&fields=user_id,uid,nick,sex,buyer_credit,seller_credit,location,created,last_visit,birthday,type,status,alipay_no,alipay_account,alipay_account,email,consumer_protection,alipay_bind,avatar&sign_method=md5"
 */
#define TOP_API_USER_GET_TEMPLATE                       @"http://gw.api.taobao.com/router/rest?sign=%%sign%%&timestamp=%%timestamp%%&v=2.0&app_key=%%appkey%%&method=%%method%%&format=xml&nick=%%nick%%&fields=user_id,uid,nick,sex,buyer_credit,seller_credit,location,created,last_visit,birthday,type,status,email,consumer_protection,avatar&sign_method=md5"

/*
 需要放后在线参数中去
 #define TOP_API_USERS_GET_TEMPLATE                      @"http://gw.api.taobao.com/router/rest?sign=%%sign%%&timestamp=%%timestamp%%&v=2.0&app_key=%%appkey%%&method=%%method%%&format=xml&nicks=%%nicks%%&fields=user_id,uid,nick,sex,buyer_credit,seller_credit,location,created,last_visit,birthday,type,status,alipay_no,alipay_account,alipay_account,email,consumer_protection,alipay_bind,avatar&sign_method=md5"
 */
#define TOP_API_USERS_GET_TEMPLATE                      @"http://gw.api.taobao.com/router/rest?sign=%%sign%%&timestamp=%%timestamp%%&v=2.0&app_key=%%appkey%%&method=%%method%%&format=xml&nicks=%%nicks%%&fields=user_id,uid,nick,sex,buyer_credit,seller_credit,location,created,last_visit,birthday,type,status,email,consumer_protection,avatar&sign_method=md5"

/* Top huabao API*/
#define TOP_API_HUABAO_POSTER_GET                       @"taobao.huabao.poster.get"
#define TOP_API_HUABAO_POSTER_GOODSINFO_GET             @"taobao.huabao.poster.goodsinfo.get"



#define TAOBAO_3G_URL_TEMPLATE                          @"http://a.m.tmall.com/i%%productid%%.htm"
#define TAOBAO_PRODUCT_URL_TEMPLATE                     @"http://detail.tmall.com/item.htm?&id=%%productid%%"





#define Y_YES                                           @"YES"
#define Y_NO                                            @"NO"
#define Y_IS_YES(str)                                   [Y_YES isEqualToString:str]
#define Y_IS_NO(str)                                    [Y_NO isEqualToString:str]
#define Y_SUCCESS                                       @"SUCCESS"
#define Y_IS_SUCCESS                                    [Y_SUCCESS isEqualToString:str]


/* --------------------------------- */
//{"api":"xxx","v":"*","ret":["xxx"],"data":{}}

#define _PAST_DUE_                                  60 * 30 // 30 分钟

#define _TTID_SEND_URL_TEMPLATE_            @"http://m.taobao.com/syscheck.htm?ttid=%%ttid%%&imei=%%imei%%&imsi=%%imsi%%&clt_act=startup"


#define _TOP_SID_PARAM_                     @"%%sid%%"
#define _WAP_WANGWANG_URL_                  @"http://wangwang.wap.taobao.com/ww/wap_ww_lately_lk_man.htm?sid=%%sid%%"



//“渠道代码_AppKey@应用名称_平台名称_版本号_特殊参数（可选）”
#define _TTID_FOR_YMALL_                   @"400000_12548142@ykgw_iPad_2.0.4_yuikemall"
#define _TTID_FOR_YMALL_IPHONE             @"400000_12548142@ykgw_iPhone_1.0.0_yuikemall"



#endif
